/****************************************************************
* @file   : eth_types.h
* @author : NingJian (freegodly@gmail.com)
* @date   : 05/26/21 09:37:34
* @brief   : 
****************************************************************/
#pragma once

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif


#define ETHASH_EPOCH_LENGTH 30000
#define ETHASH_LIGHT_CACHE_ITEM_SIZE 64
#define ETHASH_FULL_DATASET_ITEM_SIZE 128
#define ETHASH_NUM_DATASET_ACCESSES 64



union hash256
{
    uint64_t word64s[4];
    uint32_t word32s[8];
    uint8_t bytes[32];
    char str[32];
};

union hash512
{
    uint64_t word64s[8];
    uint32_t word32s[16];
    uint8_t bytes[64];
    char str[64];
};

union hash1024
{
    union hash512 hash512s[2];
    uint64_t word64s[16];
    uint32_t word32s[32];
    uint8_t bytes[128];
    char str[128];
};

union hash2048
{
    union hash512 hash512s[4];
    uint64_t word64s[32];
    uint32_t word32s[64];
    uint8_t bytes[256];
    char str[256];
};


struct eth_context
{
    const int epoch_number;
    const size_t light_cache_num_items;
    const union hash512* const light_cache;
    const uint32_t* const l1_cache;
    const size_t full_dataset_num_items;
    const union hash1024* const full_dataset;
};

struct eth_result
{
    bool solution_found = false;
    uint64_t nonce = 0;
    hash256 final_hash = {};
    hash256 mix_hash = {};
};

#ifdef __cplusplus
}
#endif
